package src.DAO;

import src.jdbc.PostgreSQL;
import src.Entities.Programa;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
/**
 *
 * @author Rodrigo
 */
public class ProgramaDAO {

    public ArrayList selectPrograma(String sql) {
        ArrayList results = new ArrayList();
        try {
            Connection con = PostgreSQL.getConnection();
            Statement select = con.createStatement();
            ResultSet query = select.executeQuery(sql);
            while (query.next()) {
                Programa program = new Programa(query.getInt("programa_id"),
                        query.getString("nombre"));
                results.add(program);
            }
        } catch (Exception e) {
            System.out.println(e);
        }
        return results;
    }
}
